"use client";
import { GroupType, PrizeTypes } from "@/api/home";
import { server } from "@/utils/client";
import React from "react";
import HomeTabs from "./_home/HomeTabs";

// const HomeTabs = () => import("./_home/HomeTabs");

const TIME = 0;
const getGames = async () => {
    return server
        .request<GroupType[]>({
            url: "/v1/api/front/game_list",
            method: "POST",
            // next: { revalidate: TIME },
        })
        .then((res) => {
            if (res.code === 200) return res.data;
            return [];
        });
};

const getPrizeApi = () => {
    return server.request<PrizeTypes[]>({
        url: "/v1/api/front/games_notice_win",
        method: "post",
    });
};

export default function Page(props: any) {
    const [group, setGroup] = React.useState<GroupType[]>([]);

    React.useEffect(() => {
        getData();
    }, []);
    const getData = async () => {
        const groupData = await getGames();
        setGroup(groupData);
    };
    //const group = await getGames();
    // const result = await getPrizeApi();
    if (!group?.length) return null;
    return (
        <HomeTabs
            tabs={group}
            // prize={result?.data || []}
        />
    );
}
